﻿@model List<HANS_BackStage.Model.DbModel.Backstage_permission>
@{
    ViewBag.Title = "权限列表";
}
@section Styles{
<style type="text/css">
    .x_title h2 small {
    display:inline;
}
    </style>    
}
@section Scripts{
    <script type="text/javascript">
        $(function () {
            $('#permissionList').nestable({
                maxDepth: 5
            }).on('change', function (e) {
                console.log($(e.target).nestable('serialize'));
            });

            window.getConfirmAttachData = function () {
                return { "orderInfo": JSON.stringify($("#permissionList").nestable('serialize')) };
            }


            Messagetoastr.TypeShow.info("提示：请小心操作本页面");
        })
    </script>
    }
@helper OrderList(List<HANS_BackStage.Model.DbModel.Backstage_permission> permissions) { 
    <ol class="dd-list">
        @foreach (var item in permissions)
        {
            <li class="dd-item dd3-item" data-id="@item.Id">
                <div class="dd-handle dd3-handle"></div>
                <div class="dd3-content">
                    @(item.Permissionname)@(item.Ismenu ? "" : "【非菜单】")
                    &nbsp;&nbsp;&nbsp; 
                    @(item.Description)
                    <div id="datatable_filter" class="dataTables_filter">
                        <a href="@Url.Action("UpdatePermission", "Account",new { id=item.Id})" class="btn btn-xs btn-success"><i class="fa fa-edit"></i>修改</a>
                        <a data-confirmed-text="确认删除？"
                           data-confirmed-button="删除"
                           data-confirmed-cancel-button="取消"
                           data-confirmed-button-class="btn-danger"
                           data-confirmed-url="@Url.Action("DeletePermission", "Account", new { id=item.Id})"
                           class="btn btn-danger btn-xs js-confirm-submit">
                            <!--js-confirm-submit js post 提交-->
                            <i class="fa fa-trash-o"></i>删除
                        </a>
                    </div>
                   
                </div>
                @{ 
                    List<HANS_BackStage.Model.DbModel.Backstage_permission> childrens = HANS_BackStage.Impl.Role_PermiServices.GetPerChildrenList(item.Id);
                    if (childrens.Count>0)
                    {
                        @OrderList(childrens);
                    }

                }

            </li>
        }
    </ol>
    }
<div class="x_panel">
    <!--beginHead-->
    <div class="x_title">
        <h2>权限列表<small>HANS</small></h2>
        <ul class="nav navbar-right panel_toolbox">
            <li>
                <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
            </li>
        </ul>
        <div class="clearfix"></div>
    </div>
    <!--endHead-->
    <div class="x_content">
        <div id="datatable_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer form">
            <!--beginSearch-->
            <form>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="dataTables_length" id="datatable_length">
                            <a href="@Url.Action("CreatePermission","Account")" class="btn btn-success">
                                 <i class="fa fa-plus"></i>添加
                            </a>
                            <a data-confirmed-text="确认保存上下级关系？"
                               data-confirmed-button="保存"
                               data-confirmed-cancel-button="取消"
                               data-confirmed-button-class="btn-success"
                               data-confirmed-url="@Url.Action("SavePermissionOrder", "Account")"
                               class="btn btn-success js-confirm-submit">
                                <!--js-confirm-submit js post 提交-->
                                <i class="fa fa-save"></i>保存
                            </a>
                        </div>
                    </div>
                </div>
            </form>
            <!--endSearch-->
            <!--begiContent-->
            <div class="row">
                <div  id="permissionList" class="col-sm-12 ">
                    @OrderList(Model)
                </div>
            </div>
            <!--endContent-->
        </div>
    </div>
</div>